const path = require("path");
var webpack = require("webpack");

function resolve(dir) {
  return path.join(__dirname, "..", dir);
}
module.exports = {
  mode: "production",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "[name].js",
    libraryTarget: "umd2",
    library: "Mogo"
  },
  resolve: {
    aliasFields: ["weapp", "browser"]
  },
  devtool: "source-map",
  node: {
    // do not polyfill Buffer
    Buffer: false,
    stream: false,
    process: false
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: "babel-loader"
      },
      {
        test: /\.js$/,
        enforce: "pre",
        include: [path.resolve(__dirname, "../src")],
        use: [
          {
            loader: "webpack-strip-block",
            options: {
              start: "NODE-ONLY:start",
              end: "NODE-ONLY:end"
            }
          }
        ]
      }
    ]
  },
  // 代码模块路径解析的配置
  optimization: {
    minimize: true
  },
  plugins: [
    // new webpack.EnvironmentPlugin(["CLIENT_PLATFORM"]),
    // new webpack.optimize.minimize({
    //   include: /-min\.js$/,
    //   sourceMap: true
    // }),
  ]
};
